package com.lu.service;

import com.lu.dao.ds2.MessageDao;
import com.lu.model.Message;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional("transactionManager2")
public class MessageService {

    @Resource(name = "messageDao2")
    private MessageDao messageDao2;
    @Resource
    private com.lu.dao.ds1.MessageDao messageDao;


    public void save1() {
        Message message = new Message();
        message.setName("test");
        message.setContent("heheh");
        messageDao.save(message);

    }

    public void save2() {

        for (int i = 0; i < 10; i++) {
            Message message1 = messageDao2.get2(new Long(i));
            Message message = new Message();
            message.setName((message1 == null ? "test" : message1.getName()) + "-" + i);
            message.setContent((i + 1) + "");
            messageDao2.save(message);
        }


    }
}
